import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import boxmap from '../views/boxmap.vue'
import store from '../store'

Vue.use(VueRouter)
const routes = [{
	path:'/',
	name:'boxmap',
	component:boxmap
}
	// {
	// 	path: '/',
	// 	name: 'login',
	// 	component: () => import('@/views/login/index.vue'),
	// 	children: [{
	// 			path: '/loginlogin',
	// 			name: 'loginlogin',
	// 			component: () => import('@/views/login/login.vue'),
	// 		},
	// 		{
	// 			path: '/',
	// 			name: 'home',
	// 			component: () => import('@/views/login/home.vue'),
	// 		}
	// 	]
	// }
]

const router = new VueRouter({
	mode: 'history',
	base: process.env.BASE_URL,
	routes
})

// 路由进行存储使用
store.commit("SET_ROU", routes)

router.beforeEach((to, from, next) => {
	// store.commit("SET_TOROU", to)
	// store.commit("SET_FROMROU", from)
	
	// if (to.name !== 'login') {
	// 	if (!window.sessionStorage.tokenId) {
	// 		console.log("自己去登录页！", to)
	// 		// router.push({name: 'login'})
	// 	}
	// }
	// 解决跳转综合评估子平台默认子路由失效的问题
	// if(to.name == 'general'){
	// 	return router.push({name:'relationship'})
	// }
	next()
})

export default router
// 防止路由重复
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}
